<?php

namespace App\Console\Commands;

use App\Http\Controllers\GiftBagController;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class GrantGiftBag extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'giftBag:grantGiftBag {all=0}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '发放排行榜礼物';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(  )
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $all = (int)$this->argument('all');

        if (0 === $all) {
            $this->grantGiftBagRank();
        } elseif (1 === $all) {
            $this->grantGiftBag();
        } elseif (2 === $all) {
            $this->anewAwardGift();
        }

    }


    private function grantGiftBag()
    {
        $gift = new GiftBagController();
        return $gift->awardGiftToRank();

    }

    private function grantGiftBagRank()
    {
        $gift = new GiftBagController();
        $rank = $gift->giftRank();
        return $rank;
    }

    private function anewAwardGift()
    {
        $gift = new GiftBagController();
        $rank = $gift->anewAwardGift();
        return $rank;
    }


}
